<template>
  <div class="app-container">
    <div class="seatch">
      <el-input
        v-model="listQuery.keyword"
        placeholder="按操作人搜索"
        @keyup.enter.native="searchName($event)"
      >
        <i slot="prefix" class="el-input__icon el-icon-search" @click="getList()" />
      </el-input>
    </div>
    <div class="content">
      <el-table
        v-loading="listLoading"
        align="center"
        :data="tableData"
        style="width: 100%"
      >
        <el-table-column
          prop="operator"
          align="center"
          label="操作人"
        />
        <el-table-column
          prop="log"
          align="center"
          label="操作内容"
        />
        <el-table-column
          align="center"
          prop="createAt"
          label="操作时间"
        />
      </el-table>
      <div class="pageination-div">
        <pagination v-show="total>0" :total="total" :page.sync="listQuery.pageNum" :limit.sync="listQuery.pageSize" @pagination="getList" />
      </div>

    </div>

  </div>

</template>

<script>
import Pagination from '@/components/pagination'
import { getLogs } from '@/api/log'
export default {
  components: {
    Pagination
  },
  data() {
    return {
      tableData: [],
      total: 0,
      listLoading: true,
      listQuery: {
        keyword: null,
        pageNum: 1,
        pageSize: 10
      }
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    sizeChange(val) {
      this.pageNum = val
    },
    currentChange(val) {
      this.currentPage = val
    },
    searchName(e) {
      this.listQuery.keyword = e.target.value
      this.getList()
    },
    // 获取数据
    async getList() {
      const res = await getLogs(this.listQuery)
      if (res.code === 200) {
        this.tableData = res.data.list
        this.total = res.data.total || 0
        this.pages = res.data.pages || 0
        this.listLoading = false
      }
    }
  }
}
</script>
<style lang="scss" scoped>
// .app-container{
//   .seatch{
//     width:180px;
//     height:32px;
//     border-radius:2px;
//     // border:1px solid rgba(35,189,234,0.7);
//     position: absolute;
//     right: 20px;
//     margin-top: -45px;
//   }
//   .content{
//     margin: 66px 0 0 0;
//   }
// }
</style>
